Skip to content

Improve error handling and messages in BaseArray#281

Merged
OriolAbril merged 2 commits intoarviz-devs:mainfrom
ShivamRajSri:refactor-array-axis-handling
Mar 2, 2026
Merged

Improve error handling and messages in BaseArray#281
OriolAbril merged 2 commits intoarviz-devs:mainfrom
ShivamRajSri:refactor-array-axis-handling

Conversation

@ShivamRajSri
Copy link
Contributor

@ShivamRajSri ShivamRajSri commented Jan 9, 2026

This PR replaces a couple of internal assert statements in BaseArray with explicit ValueError checks and clearer error messages.

The goal is to make the validation more robust (since assert can be disabled in optimized runs) and to provide more informative errors to users when inputs have incompatible shapes or axes.

There are no functional changes — just safer validation and clearer error handling.

@read-the-docs-community
Copy link

read-the-docs-community bot commented Jan 9, 2026

Documentation build overview

📚 arviz-stats | 🛠️ Build #31628351 | 📁 Comparing 8ea6967 against latest (0a1b483)


🔍 Preview build

Show files changed (11 files in total): 📝 11 modified | ➕ 0 added | ➖ 0 deleted
File Status
api/generated/arviz_stats.bayes_factor.html 📝 modified
api/generated/arviz_stats.eti.html 📝 modified
api/generated/arviz_stats.hdi.html 📝 modified
api/generated/arviz_stats.histogram.html 📝 modified
api/generated/arviz_stats.kde.html 📝 modified
api/generated/arviz_stats.loo_kfold.html 📝 modified
api/generated/arviz_stats.loo_score.html 📝 modified
api/generated/arviz_stats.mean.html 📝 modified
api/generated/arviz_stats.median.html 📝 modified
api/generated/arviz_stats.mode.html 📝 modified
api/generated/arviz_stats.qds.html 📝 modified

Copy link
Member

@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title is extremely scary, luckily the actual changes have nothing to do with it or with the PR description. Please update it.

Clearer error messages is usually a good idea

if range.shape[:-1] != broadcased_shape:
raise ValueError(
"`range` has incompatible shape. "
f"Expected shape (*, 2) with leading dimensions {broadcased_shape}, "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can build the whole expected shape here so it is clearer instead of the *, 2 then showing the leading dimensions

@ShivamRajSri ShivamRajSri changed the title Refactor: simplify axis handling in BaseArray array interface Improve error handling and messages in BaseArray Feb 15, 2026
@ShivamRajSri
Copy link
Contributor Author

Sorry for the delayed response @OriolAbril I completely missed your comment last week.
I’ve now updated the implementation by replacing the internal assert statements with explicit ValueError checks and clearer error messages, as suggested. This makes the validation more robust and avoids relying on assertions that could be skipped in optimized runs.
Please let me know if you’d like any further adjustments.

@OriolAbril OriolAbril force-pushed the refactor-array-axis-handling branch from 3c7439e to 8ea6967 Compare March 2, 2026 18:34
OriolAbril
OriolAbril approved these changes Mar 2, 2026
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 10.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.42%. Comparing base (92cbee1) to head (8ea6967).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/arviz_stats/base/array.py 10.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #281      +/-   ##
==========================================
- Coverage   84.50%   84.42%   -0.09%     
==========================================
  Files          42       42              
  Lines        5823     5829       +6     
==========================================
  Hits         4921     4921              
- Misses        902      908       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@OriolAbril OriolAbril merged commit 4383159 into arviz-devs:main Mar 2, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants